import QtQuick 2.0

Rectangle {
    id: iconButtonRootID

    property var iconImageSource: ""

    signal iconButtonClicked()

    Image {
        id: icon
        width: parent.width
        height: parent.height
        source: iconButtonRootID.iconImageSource
        fillMode: Image.PreserveAspectFit
        clip: true
        anchors.top: parent.top
        anchors.right: parent.right
        anchors.left: parent.left
        anchors.bottom: parent.bottom
        anchors.margins: 1
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true

        //接受左键和右键输入
        acceptedButtons: Qt.LeftButton
        onClicked: {
            parent.iconButtonClicked()
        }
    }
}
